<?php
/**
 * Project: HTPHouDuan
 * User: xilibo
 * Date: 2018/2/5 0005
 */

namespace app\admin\controller;

use cmf\controller\AdminBaseController;

/**
 * 运营统计报表相关
 * Class OperationController
 * @package app\admin\controller
 */
class OperationController extends AdminBaseController
{
    private $userModel;

    private $userBalanceLogModel;

    private $gameModel;

    public function _initialize()
    {
        parent::_initialize();
        $this->userBalanceLogModel = model('user_balance_log');
        $this->userModel = model('user');
        $this->gameModel = model('game');
    }


    public function index()
    {
        $countBalanceLog =$this->userBalanceLogModel->count();
        $countUser = $this->userModel->count();
        $countGame = $this->gameModel->count();

        $countList = [
            '余额变更数' => $countBalanceLog,
            '用户数' => $countUser,
            '游戏数' => $countGame,
        ];

        $this->assign('countList', $countList);

        return $this->fetch();
    }

    public function rechargeLog()
    {
        $condition = [
            'page' => $this->request->get('page', 1, 'intval'),
            'page_size' => $this->request->get('pgsize', 20, 'intval'),
        ];
        $rechargeLog = model('user_balance_log')->getList($condition);
        $this->assign('rechargeLogList', $rechargeLog);
        $this->assign('page', $rechargeLog->render());

        return $this->fetch();
    }

}